#ifndef UNITITEM_H
#define UNITITEM_H

#include <QtCore>
#include <QtGui>

#include "general.h"

enum UnitType
  {
    Type1 = 0x1,   // 00001
    Type2 = 0x2,   // 00010
    Type3 = 0x4,   // 00100
    Type4 = 0x8,   // 01000
    Type5 = 0x10   // 10000
  };
Q_DECLARE_FLAGS(UnitTypes, UnitType)
Q_DECLARE_OPERATORS_FOR_FLAGS(UnitTypes)

class UnitItem : public QGraphicsObject
{
    struct UnitProperties
    {
        qreal   life;
        qreal   speed;
        qreal   armor;
        UnitType   unitType;
        UnitProperties() : life(50), speed(50), armor(0), unitType(Type1) {}
    };
    Q_OBJECT
public:
    UnitItem(QGraphicsObject * parent = 0);
    ~UnitItem();
    QRectF boundingRect() const;
    inline UnitProperties unitProperties() const {return m_properties;}
    inline void setWaypoints(const Waypoints& ways) { m_waypoint = ways; setPos(m_waypoint.at(0)); }
protected:
    void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
private:
    UnitProperties m_properties;
    Waypoints m_waypoint;
};

#endif // UNITITEM_H
